#include <iostream>
#include <random>
#include <ctime>
#include "test.h"
using namespace std;



int main()
{
    default_random_engine generator(114);
    uniform_int_distribution<int> distribution(1, 4);
    int arr[8][8];
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            arr[i][j]= distribution(generator);
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"输入两个待交换数的坐标:";
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int temp = 0;
    temp = arr[x1][y1];
    arr[x1][y1] = arr[x2][y2];
    arr[x2][y2] = temp;
    cout<<"交换后的数组:"<<endl;
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    int arrx1[8];
    int arry1[8];
    int arrx2[8];
    int arry2[8];
    for(int i=0;i<8;i++)
    {
        arrx1[i] = arr[x1][i];
        arry1[i] = arr[i][y1];
        arrx2[i] = arr[x2][i];
        arry2[i] = arr[i][y2];
    }
    cout<<"待交换数的坐标数组:"<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arrx1[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arry1[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arrx2[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arry2[i]<<" ";
    }
    cout<<endl;
    BejSolve(arrx1);
    BejSolve(arry1);
    BejSolve(arrx2);
    BejSolve(arry2);
        cout<<"待交换数的坐标数组:"<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arrx1[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arry1[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arrx2[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        cout<<arry2[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<8;i++)
    {
        arr[x1][i] = arrx1[i];
        arr[i][y1] = arry1[i];
        arr[x2][i] = arrx2[i];
        arr[i][y2] = arry2[i];
    }
    cout<<"解出后的数组:"<<endl;
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    

    return 0;
}